import React, { Component } from 'react'
import { Switch, Route , Redirect} from 'react-router-dom'
import Admin from '@pages/Admin'
import Login from '@pages/Login'
import NotFound from '@pages/NotFound'
import { isLogin } from '@utils'
export default class App extends Component {
  render() {
    return (
      <div>
        <Switch>
          <Route path="/admin" render={(routeProps)=>{
            // 判断是否登录
            if(isLogin()) {
              return <Admin {...routeProps}/>
            }else{
              return <Redirect to="/login"/>
            }
          }}/>
          <Route path="/login" component={Login}/>
          <Route path="/404" component={NotFound}/>
          <Redirect to="/admin" from="/" exact/>
          <Redirect to="/404"/>
        </Switch>
      </div>
    )
  }
}
